<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/app.css">
		<style>
			h4.mui-ellipsis {
				line-height: 20px;
			}
			.readed {
				font-weight: normal;
			}
			.due {
				font-weight: normal;
				color: #8f8f94;

			}
			.mui-input-row {
				margin: 5px 5px 0;
			}
			.mui-input-row input, .mui-input-row textarea{
				margin-bottom: 0;
			}
			
			.mui-input-row select{
				-webkit-appearance: menulist-button;
				border: 1px solid rgba(0,0,0,.2)!important;
				border-radius: 3px;
				margin-bottom: 0;
				padding-left: 15px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">报修</h1>
		</header>

		<div class="mui-content" style="background: white;">
			
			<div class="mui-input-row">
				<select id="house" onchange="findByHouseId()">
					<option value="">请选择房屋</option>
				</select>
			</div>			
			<div class="mui-card">
				<ul class="mui-table-view" id="parent">
				<li class="mui-table-view-cell mui-checkbox mui-left">
						<input name="checkbox" type="checkbox">Item 7
					</li>
					<li class="mui-table-view-cell mui-checkbox mui-left">
						<input name="checkbox" type="checkbox">Item 8
					</li>
				</ul>
				</div>

			<div style="margin: 0 5px 5px;">
				<button class="mui-btn mui-btn-success mui-btn-block" id="submit">提交</button>
			</div>
		</div>
		
		<script id="tmpl" type="text/html">
			{{each datas as value i}}
				<li class="mui-table-view-cell mui-checkbox mui-left">
					<input name="checkbox" type="checkbox">{{value.feesName}}
				</li>
				<div class="info">
					<h5 style="font-weight: 700; color: #333; font-size: 16px;padding-left: 5px;">
						{{value.allNum}}
						<span class="mui-badge mui-badge-success">{{value.total}}</span>
					</h5>
					<table>
						<tr>
							<td class="left">单价</td>
							<td class="right">{{value.price}}</td>
						</tr>
						<tr>
							<td class="left">用量</td>
							<td class="right">{{value.count}}</td>
						</tr>
						<tr>
							<td class="left" align="left" valign="top">总计</td>
							<td class="right">{{value.total}}</td>
						</tr>
					</table>
				</div>
	        {{/each}}
	        
		</script>
	
	</body>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/template.js"></script>
	<script src="../../js/app.js"></script>
	<script src="../../js/_API.js"></script>
	<script>
		mui.init();
		
		mui.plusReady(function(){
			_API.ajax2('community/house/findByPeople', {}, true)
			.success(function(json){
				var str = '<option value="">请选择房屋</option>';
				for(var i=0; i<json.data.length; i++) {
					var d = json.data[i];
					str += '<option value="' + d.id + '">' + d.allNum + '</option>'
				}
				document.getElementById("house").innerHTML = str;
			}).error(function(json){
	       	 	plus.nativeUI.toast(json.msgInfo);
			});
		});
		
		var getVal = function(){
			var data = {
				houseId : document.getElementById("house").value,
				isPay : 'N'
			}
			if(!data.houseId){
				alert("请选择房屋");
			}
			return data;
		}
			
		function findByHouseId(){
			var data = getVal();
			_API.ajax2('community/fees/findByHouseId', data, true)
			.success(function(json){
				alert(JSON.stringify(json))
		        	var html = template('tmpl', {datas: json.data});
				document.getElementById('parent').innerHTML = html;
			}).error(function(json){
	     	   	plus.nativeUI.toast(json.msgInfo);
			});
		};
	</script>
</html>